package bb.lanxing.util.ui;

import android.app.Activity;
import android.os.SystemClock;
import android.view.View;

import androidx.fragment.app.Fragment;
import bb.lanxing.R;
import kotlin.Lazy;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.Intrinsics;

public final class ViewExtensionsKt {
    private static final int FAST_CLICK_THRSHOLD = 300;

    public static final void gone(View view) {
        Intrinsics.checkNotNullParameter(view, "<this>");
        view.setVisibility(View.GONE);
    }

    public static final void visible(View view) {
        Intrinsics.checkNotNullParameter(view, "<this>");
        view.setVisibility(View.VISIBLE);
    }

    public static final /* synthetic */ <T> T ignore(Function0<? extends T> what) {
        Intrinsics.checkNotNullParameter(what, "what");
        try {
            return what.invoke();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    public static final /* synthetic */ <T extends View> Lazy<T> bind(Activity activity, int i) {
        Intrinsics.checkNotNullParameter(activity, "<this>");
        Intrinsics.needClassReification();
//        return (Lazy<T>) LazyKt.lazy(bind(activity, i));
//        return LazyKt.lazy(new ViewExtensionsKt$bind$1(activity, i));
        return null;
    }

    public static final /* synthetic */ <T extends View> Lazy<T> bind(Fragment fragment, int i) {
        Intrinsics.checkNotNullParameter(fragment, "<this>");
        Intrinsics.needClassReification();
//        return (Lazy<T>) LazyKt.lazy(bind(fragment, i));
//        return LazyKt.lazy(new ViewExtensionsKt$bind$2(fragment, i));

        return null;
    }

    public static final /* synthetic */ <T extends View> Lazy<T> bind(View view, int i) {
        Intrinsics.checkNotNullParameter(view, "<this>");
        Intrinsics.needClassReification();
//        return (Lazy<T>) LazyKt.lazy(bind(view, i));
        //return LazyKt.lazy(new ViewExtensionsKt$bind$3(view, i));
        return null;
    }

    public static final int getFAST_CLICK_THRSHOLD() {
        return FAST_CLICK_THRSHOLD;
    }

    public static final boolean isFastClick(View view, int i) {
        long elapsedRealtime = SystemClock.elapsedRealtime();
        if (elapsedRealtime - getTriggerTime(view) >= i) {
            setTriggerTime(view, elapsedRealtime);
            return false;
        }
        return true;
    }

    private static final long getTriggerTime(View view) {
        Object tag = view.getTag(R.id.tag_click_trigger);
        Long l = tag instanceof Long ? (Long) tag : null;
        if (l != null) {
            return l;
        }
        return 0L;
    }

    private static final void setTriggerTime(View view, long j) {
        view.setTag(R.id.tag_click_trigger, j);
    }
}